package JDK8.Lambda;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;

public class IterateListLambdaAppMain {
    public static void main(String[] args) {
        List<String> list = addElementsToList(new ArrayList<>());

        list.forEach(new Consumer<String>(){

            @Override
            public void accept(String s) {
                System.out.println(s);
            }
        });
        System.out.println("--------------");
        list.forEach(s -> System.out.println(s));
        System.out.println("-------------");
        list.forEach(s -> {System.out.println(s.toCharArray());});

        list.stream().filter(s -> s.length() > 4).map(String::toCharArray).collect(Collectors.toList()).forEach(System.out::println);
    }

    public static List<String> addElementsToList(List<String> list){
        for(int i = 0; i < 22; i++){
            list.add("str" + i);
        }
        return list;
    }


}

